import request from '@/utils/request';
import { AxiosPromise } from 'axios';

/**
 * 查询财务单据列表
 * @param query
 * @returns {*}
 */

export const listBill = (query?: BillVO): AxiosPromise<BillVO[]> => {
  return request({
    url: '/fms/bill/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询财务单据详细
 * @param id
 */
export const getBill = (id: number): AxiosPromise<BillVO> => {
  return request({
    url: '/fms/bill/' + id,
    method: 'get'
  });
};

/**
 * 新增财务单据
 * @param data
 */
export const addBill = (data: BillVO) => {
  return request({
    url: '/fms/bill',
    method: 'post',
    data: data
  });
};

/**
 * 修改财务单据
 * @param data
 */
export const updateBill = (data: BillVO) => {
  return request({
    url: '/fms/bill',
    method: 'put',
    data: data
  });
};

/**
 * 删除财务单据
 * @param id
 */
export const delBill = (id: number | (number | undefined)[]) => {
  return request({
    url: '/fms/bill/' + id,
    method: 'delete'
  });
};

/**
 * 执行财务单据
 * @param data
 */
export const execBill = (data: BillVO) => {
  return request({
    url: '/fms/bill/exec',
    method: 'put',
    data: data
  });
}

/**
 * 财务单据冲销
 * @param data
 */
export const backBill = (data: BillVO) => {
  return request({
    url: '/fms/bill/back',
    method: 'put',
    data: data
  });
}

/**
 * 财务单据分期
 * @param data
 */
export const divideBill = (data: BillVO) => {
  return request({
    url: '/fms/bill/divide',
    method: 'post',
    data: data
  });
};


export interface BillVO extends BaseEntity,PageQuery {
  /** 主键 */
  id?: number;

  /** 单据类型 */
  typeId?: number;

  /** 账单名称 */
  name?: string;

  /** 记账项目 */
  classificationItemId?: number;

  /** 来往单位 */
  partnerId?: number | string;

  /** 单据编号 */
  sourceId?: number;

  /** 操作员 */
  operId?: number;

  /** 应收金额 */
  costMoney?: number;

  /** 实收金额 */
  money?: number;

  /** 账户 */
  accountId?: number;

  /** 计划时间 */
  planTime?: string;

  /** 执行时间 */
  executionTime?: string;

  /** 状态 */
  status?: string;

  remark?: string;

  typeName?: string;
  accountName?: string;
  partnerName?: string;
  operName?: string;
  classificationItemName?: string;

}
